#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100010;
using ll = long long;
int a[N];
int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    ll res=0;
    sort(a, a + n);
    for (int i = 0; i < n; i++) res += a[i] * (n - i - 1);
    cout << res << endl;
    return 0;
}